<div class="modal fade " id="addRoleModal" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">新增用户角色</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal" id="addRoleForm">
                <div class="box-body">
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">角色名称</label>
                        <div class="col-sm-7">
                            <input id="addRoleRoleName" type="text" class="form-control">
                            <input type="hidden" id="addRoleId">
                        </div>
                    </div>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>

                    <button type="button" class="btn btn-primary pull-right" onclick="saveRole()">保存</button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>
<script>
    function addRoleModalInit() {
        $("#addRoleId").val("");
        $("#addRoleRoleName").val("");
    }



    function saveRole() {
        var roleName = $("#addRoleRoleName").val();
        if (roleName == null || roleName == undefined || roleName == "" || roleName.trim() == "") {
            toastr['error']("角色名称不能为空", '异常');
            return;
        }
        var data = {
            roleName: roleName,
            roleId: $("#addRoleId").val()
        };
        var url = "/permission/role/add";
        postReq(url, data, function (result) {
            if (result.success) {
                $("#roleTable").bootstrapTable("refresh");
                $("#addRoleModal").modal("hide");
                toastr['success']('新增角色成功', '提示');
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }


</script>